<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Methods option</title>
    <script type="text/javascript" src="../assets/js/vue.js"></script>
</head>
<body>
    <h1>Methods option</h1>
    <hr>
    <div id="app">
        <p>{{message}}</p>
        <button @click="add(2)">add</button>
        <p><btn @click.native="add(2)"></btn></p>
    </div>
    <button onclick="app.add(10)">外部ADD</button>

    <script type="text/javascript">
        var btn={
            template:`<button>组件ADD</button>`
        }
        var app = new Vue({
            el:'#app',
            data:{
                message:1
            },
            components:{
               "btn":btn
            },
            methods:{
                add:function(num){
                    console.log(event)
                    if(num!=''){
                        this.message+=num
                    }else{
                        this.message++
                    }
                    
                }
            }

        })
    </script>
</body>
</html>